#!/usr/bin/perl -c

package PIPL::System::Config;
use 5.006;
our $VERSION = '0.01';

=head1 NAME

PIPL::System::Config - Singleton for wrapping %Config variable

=head1 SYNOPSIS

  use PIPL::System::Config;
  $c = PIPL::System::Config->instance;
  $ver = $c->{version};

  $key = 'installsitelib';
  $dir = $PIPL::System::Config::Self->{$key};

=head1 DESCRIPTION

This singleton class gives an access to Perl's configuration informations. It
provides full OO style for B<%Config> variable.  It can be more handy than
accessing pure B<%Config> variable if unit tests are used or some wrapping
for B<%Config> is needed.

The environment variable is accessable by instance variable (B<new> or
B<instance> constructor) or by static variable
B<$PIPL::System::Config::Self>.

=cut


use strict;

use base 'PIPL::Class::Singleton';


use Config ();
use Carp qw();


# Private constructor used by singleton constructor
sub new {
    my $class = shift;
    $class = ref $class if ref $class;
    bless \%Config::Config => $class;
}


# Initialize singleton instance at start
__PACKAGE__->instance;



1;


=head1 BASE CLASSES

=over 2

=item *

L<PIPL::Class::Singleton>

=back

=head1 FIELDS

=over

=item I<value> (ro)

Return configuration information for I<value>.

  $v = $PIPL::System::Config::Self->{version};

=back

=head1 CONSTRUCTORS

=over

=item new

Create new object.

  $obj = new PIPL::System::Config;
  $v = $obj->{version};

=item instance

Return existing instance of class or create new object.

  $obj = PIPL::System::Config->instance;
  $v = $obj->{version};

=back

=head1 STATIC OBJECT INSTANCE

The class provides static object instance:

  use PIPL::System::Config;
  
  print $PIPL::System::Config::Self->{version};

=head1 SEE ALSO

L<PIPL::Class::Singleton>.

=head1 AUTHORS

Piotr Roszatycki E<lt>dexter@debian.orgE<gt>

=head1 LICENSE

Copyright 2007 by Piotr Roszatycki E<lt>dexter@debian.orgE<gt>.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

See L<http://www.perl.com/perl/misc/Artistic.html>
